package com.webdev.newtech.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.webdev.newtech.domain.TlProduct;
import com.webdev.newtech.mapper.ITlProductMapper;
import com.webdev.newtech.service.ITlProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ITlProductServiceImpl  implements ITlProductService {

    @Resource
    ITlProductMapper productMapper;


    @Override
    public int add(TlProduct product) {
        return productMapper.insert(product);
    }

    @Override
    public int remove(Integer id) {
        return productMapper.deleteById(id);
    }

    @Override
    public int update(TlProduct product) {
        return productMapper.updateById(product);
    }

    @Override
    public List<TlProduct> getList(TlProduct product) {
        QueryWrapper<TlProduct> wrapper=new QueryWrapper<>();
        wrapper.eq(product.getStatus()!=null,"status",product.getStatus() );
        wrapper.orderByAsc("order_num");
        return productMapper.selectList(wrapper);
    }

    @Override
    public TlProduct getById(Integer id) {
        return productMapper.selectById(id);
    }
}
